Macromedia Flex Article

A Step-by-Step Guide to Building an Application with Flex


Table of Contents

  1. Introduction
  2. Flex Store
  3. Code Walkthrough
  4. MXML Components
  5. ActionScript Components
  6. Writing Code

Flex Store

To see the Flex Store, browse to [flex default server]/samples/flexstore/flexstore.mxml on your server or browse the online version.

  1. Browse the products by selecting items from the grid.

    The first thing you notice is that the application is structured as a basic master/detail which, although simple, can’t be done in HTML. As you choose products from the grid on the left, the product detail displays on the right. A basic HTML application would require the browser to reload the page to show detail. Flex applications cache the data on the client, minimizing roundtrips to the server and making the application highly responsive.

  2. Move the slider under the product list to filter products based on price.

    As you move the slider, the products that don’t meet the price criteria fade, so that you see only those that do. This example of guided selling shows how developers can offer users visual clues that allow users to maintain context for their actions and not get lost in multiple pages.

  3. Choose Price from the Sort by pop-up menu.

    Macromedia Flash Player’s ability to maintain state on the client allows developers to implement features like client sorting so that users can view the same data in different formats. For similar functionality, a server-based application would have to go back to the server each time and often to the data source. In a Flex application, the data is cached on the client for easy manipulation and immediate response to user requests.

  4. Add items to the shopping cart by using the numeric stepper to choose quantity and selecting the Add to Cart button.

    Again, where HTML would require another page to display the items in the shopping cart, Flex displays them without page refresh, automatically calculating and displaying the total using client-side logic. This example of direct manipulation gives the user immediate feedback while maintaining the context of the overall application.

  5. Select the graphic of the item in the Product Details pane and drag it into the Shopping Cart.

    Flex contains a number of managers that allow you to easily implement advanced application functionality like drag and drop.

  6. Choose different columns in the Shopping Cart data grid to sort by that column.

    The data grid is one of the rich components in the standard Flex component library, many of which include built-in capabilities like sorting.

  7. Choose the Checkout button. The left pane displays the Accordion navigation container to help a customer step through the check out procedure.

    One of the things that is broken on the web is form processing. The checkout process is typically comprised of a number of forms; if you make a mistake early in the process, you don't find out until you submit the form, often multiple pages later. If you click the back button, you're unsure whether your entered data will still be there. Likewise, customers often abandon the process before they finish, making the rate of completed transactions far less than is acceptable. Flex provides components that let you to structure the data input process for greater usability—one example of that is the Accordion container. With the Accordion container, you can organize multiple forms in a single pane and include built-in effects to expand and contract the appropriate forms.

  8. Begin the check out process by entering your name. Click the back button in your browser, as if to buy another product (you can add additional products if you wish). Click the forward button to return to the checkout.

    With Flex's built-in history manager, users navigate with back and forward buttons, as they would in a page-based application. The Accordion container automatically preserves the state so the data you entered is still there.

  9. Enter an invalid email address and press tab to go onto the next field.

    A red border appears around the invalid form field, indicating that you entered invalid data; moving your mouse over the field displays an appropriate error message. With Flex’s powerful data binding features, developers can easily add validation to form fields, offering users immediate feedback.

  10. Choose the Shipping Information pane and select the different radio button options.

    The Order Summary updates, indicating the price based on your shipping choice, and gives you immediate feedback not only about the price of shipping but the total based on your shipping choice.